package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CheckGroupDao {
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into t_checkgroup (code, name, helpCode, sex, remark, attention) " +
            "VALUES ( #{code}, #{name}, #{helpCode}, #{sex}, #{remark}, #{attention})")
    void add(CheckGroup checkGroup);

    @Insert("insert into t_checkgroup_checkitem values (#{id},#{checkitemId})")
    void addIds(Integer id, String checkitemId);

    Page<CheckGroup> findPage(String queryString);

    @Select("select * from t_checkgroup where id=#{id}")
    CheckGroup findById(Integer id);

    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id= #{id}")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer id);

    void edit(CheckGroup checkGroup);

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id =#{id}")
    void deleteById(Integer id);

    @Select("select count(*) from t_checkgroup_checkitem where checkgroup_id=#{id}")
    Long countCheckGroupByCheckItemId(Integer id);

    @Delete("delete from t_checkgroup where id=#{id}")
    void deleteGroupById(Integer id);

    List<CheckGroup> findCheckGroupIdsBySetmealId(Integer id);

    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();
}
